package com.yc.myFilterFactory;

import lombok.extern.java.Log;
import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Mono;

@Configuration
@Log
public class RateLimiterConfig {

    @Bean
    public KeyResolver pathKeyResolver() {
        return exchange -> {
            String path = exchange.getRequest().getPath().value();
            log.info("path: " + path);
            return Mono.just(path);  // 按请求路径限流
        };
    }
}